###### RUN THIS SCRIPT FIRST ##### #-------------------------------------------#

# This script loads all packages that are required to reproduce all figures and tables.
# Please make sure that all packages are in the correct version (see below).
# It is important to run these scripts in the right order.

# Libraries
# load packages
library(tidyverse)
library(countrycode) 
library(tidylog)
library(janitor)
library(wbstats)
library(haven)
library(rworldmap)
library(vtable)
library(lme4)
library(texreg)
library(marginaleffects)
library(brglm2)
library(fixest)
library(vdemdata)


# R script 1: 01_dataprep.R
# This script prepares the transnational event data for merging and merges it with
# additional data sources (see folder "data").
source("Rscripts/01_dataprep.R")

# R script 2: 02_descriptives.R
# This script generates the descriptive figures in the paper.
source("Rscripts/02_descriptives.R")

# R script 3: 03_models.R
# This script runs all regression models in the main text and the Appendix.
source("Rscripts/03_models.R")


# Output from Session Info

# R version 4.1.0 (2021-05-18)
# Platform: x86_64-apple-darwin17.0 (64-bit)
# Running under: macOS Big Sur 11.7.6
# 
# Matrix products: default
# LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
# 
# locale:
#   [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
# 
# attached base packages:
#   [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
#   [1] vdemdata_3.0           fixest_0.10.5          brglm2_0.8.0           marginaleffects_0.10.0 texreg_1.37.5         
# [6] lme4_1.1-27            Matrix_1.3-3           vtable_1.3.4           kableExtra_1.3.4       rworldmap_1.3-6       
# [11] sp_1.4-5               haven_2.5.0            wbstats_1.0.5.9000     janitor_2.1.0          tidylog_1.0.2         
# [16] countrycode_1.4.0      forcats_0.5.1          stringr_1.5.0          dplyr_1.1.0            purrr_1.0.1           
# [21] readr_2.1.2            tidyr_1.3.0            tibble_3.2.0           ggplot2_3.4.1          tidyverse_1.3.1       
# 
# loaded via a namespace (and not attached):
#   [1] minqa_1.2.4         colorspace_2.1-0    ggsignif_0.6.1      ellipsis_0.3.2      rio_0.5.26          sjlabelled_1.1.8   
# [7] snakecase_0.11.0    fs_1.5.2            rstudioapi_0.13     ggpubr_0.4.0        farver_2.1.1        bit64_4.0.5        
# [13] fansi_1.0.4         lubridate_1.9.2     xml2_1.3.3          splines_4.1.0       knitr_1.43          spam_2.7-0         
# [19] Formula_1.2-5       jsonlite_1.8.0      nloptr_1.2.2.2      broom_0.8.0         dbplyr_2.1.1        compiler_4.1.0     
# [25] httr_1.4.3          backports_1.4.1     assertthat_0.2.1    fastmap_1.1.0       cli_3.6.0           htmltools_0.5.4    
# [31] tools_4.1.0         dotCall64_1.0-1     enrichwith_0.3.1    gtable_0.3.1        glue_1.6.2          dreamerr_1.2.3     
# [37] maps_3.4.0          Rcpp_1.0.10         carData_3.0-4       cellranger_1.1.0    vctrs_0.5.2         svglite_2.0.0      
# [43] nlme_3.1-152        insight_0.19.0      xfun_0.39           openxlsx_4.2.3      rvest_1.0.2         timechange_0.2.0   
# [49] lifecycle_1.0.3     rstatix_0.7.0       MASS_7.3-54         zoo_1.8-11          scales_1.2.1        vroom_1.5.7        
# [55] clisymbols_1.2.0    hms_1.1.1           parallel_4.1.0      sandwich_3.0-2      fields_12.5         curl_4.3.2         
# [61] gridExtra_2.3       stringi_1.7.12      maptools_1.1-1      checkmate_2.0.0     boot_1.3-28         zip_2.2.0          
# [67] rlang_1.0.6         pkgconfig_2.0.3     systemfonts_1.0.2   evaluate_0.15       lattice_0.20-44     labeling_0.4.2     
# [73] cowplot_1.1.1       bit_4.0.4           tidyselect_1.2.0    magrittr_2.0.3      R6_2.5.1            generics_0.1.3     
# [79] DBI_1.1.2           mgcv_1.8-35         pillar_1.8.1        foreign_0.8-81      withr_2.5.0         abind_1.4-5        
# [85] nnet_7.3-16         car_3.0-10          modelr_0.1.8        crayon_1.5.1        utf8_1.2.3          tzdb_0.3.0         
# [91] rmarkdown_2.13      viridis_0.6.1       grid_4.1.0          readxl_1.4.0        data.table_1.14.2   reprex_2.0.1       
# [97] digest_0.6.31       webshot_0.5.2       numDeriv_2016.8-1.1 munsell_0.5.0       viridisLite_0.4.1  